import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

MainView {
    id: root
    width: 800
    height: 391
    property color btnColor: "#7080C0"
    property int btnHeight: 50
    property int btnWidth: 110
    signal startLoad
    ListModel{
            id:model1
        }
    onStartLoad: {
        var myMap=mytables.weighMap;
        for (let key in myMap) {
            //var data={ "key": qsTr("设备")+key, "value": Number(key) }
            model1.append({ "key": qsTr("设备")+key, "value": Number(key) })
        }
    }
    Component.onCompleted: {
        startLoad()
    }
    function getAddrs(){
        var lst=[];
        for(let i = 0;i<256;i++){
            lst.push(i)
        }
        return lst;
    }
    Rectangle{
        id:presetMainRec
        width:800
        height: 300
        color:"transparent"
    GridLayout{
        id: presetPosSettingsLayout
        rows: 4
        columns: 4
        anchors.centerIn: parent
        rowSpacing: 40
        MyComboBox
        {
            id: posIndex
            isListModel: true
            textRole: "key"
            font.pixelSize: 20
            Layout.row: 0
            Layout.column: 0
            Layout.columnSpan: 2
            Layout.preferredWidth: 160
            Layout.preferredHeight: 40
            model:model1
            currentIndex: 0
        }
        Button
        {
            Layout.row:1
            Layout.column:0
            Layout.preferredWidth: btnWidth
            Layout.preferredHeight: btnHeight
            // x: 152
            // y: 13
            text: qsTr("通道号")
            font.pixelSize: 18
            background: Rectangle{
                color: btnColor
                    }
            onClicked: {
                cmbAddr.popup.open()
                //miniKeyBoard.lineValue = "";
                //miniKeyBoard.textInput=oldPwd;
            }
        }
        MyComboBox
        {
            id: cmbAddr
            font.pixelSize: 20
            Layout.row: 1
            Layout.column: 1
            Layout.columnSpan: 2
            Layout.preferredWidth: btnWidth
            Layout.preferredHeight: btnHeight
            //model:getAddrs()
            currentIndex: -1
        }
        Button
        {
            Layout.row:2
            Layout.column:0
            Layout.preferredWidth: btnWidth
            Layout.preferredHeight: btnHeight
            // x: 152
            // y: 13
            text: qsTr("轴号")
            font.pixelSize: 18
            background: Rectangle{
                color: btnColor
                    }
            onClicked: {
                cmbAddr.popup.open()
                //miniKeyBoard.lineValue = "";
                //miniKeyBoard.textInput=oldPwd;
            }
        }
        MyComboBox
        {
            id: cmbAxis
            font.pixelSize: 20
            Layout.row: 2
            Layout.column: 1
            Layout.columnSpan: 2
            Layout.preferredWidth: btnWidth
            Layout.preferredHeight: btnHeight
            model:getAddrs()
            currentIndex: -1
        }

}

Row {
    x: 361
    y: 281
    spacing: 10
    Button {
        id: btnAdd
        width: 100
        height: 100
        text: qsTr("添加")
        font.pixelSize: 25
        palette.buttonText: "white"
        Connections {
            target: btnAdvSettingsOK
            function onClicked() {


            }
        }
        background: Rectangle {
            color: "#c070b0"
            border.width: 0
        }
    }
    Button {
        id: btnPrePosSettingsOK
        width: 100
        height: 100
        text: qsTr("保存")
        font.pixelSize: 25
        palette.buttonText: "white"
        Connections {
            target: btnAdvSettingsOK
            function onClicked() {


            }
        }
        background: Rectangle {
            color: "#c070b0"
            border.width: 0
        }
    }
    Button {
        id: btnDel
        width: 100
        height: 100
        text: qsTr("删除")
        font.pixelSize: 25
        palette.buttonText: "white"
        Connections {
            target: btnReturn
            function onClicked() {
                //rectangle.selectedView = 4
                bottomBar.selected=4
//                myLoader.visible=false;
//                myLoader.visible=true
                myLoader.source="SettingsPanel.qml"
            }
        }
        background: Rectangle {
            color: "#c070b0"
            border.width: 0
        }
    }
    Button {
        id: btnReturn
        width: 100
        height: 100
        text: qsTr("返回")
        font.pixelSize: 25
        palette.buttonText: "white"
        //Connections {
        //   target: btnReturn
            onClicked: {
                //rectangle.selectedView = 4
                bottomBar.selected=4
//                myLoader.visible=false;
//                myLoader.visible=true
                myLoader.source="SettingsPanel.qml"
            }
        //}
        background: Rectangle {
            color: "#b0b0d0"
            border.width: 0
        }
    }
}

    }
    Timer{
        id:presetTimmer
        interval: 1200
        running: false
        repeat: false
        onTriggered: presetLoader.visible = false
    }
   MyBuzyIndicator{
       anchors.centerIn: parent
       id: presetLoader
       visible:false
       z:101
   }
    Dialog {
        anchors.centerIn: parent
        id: prePointSaveOKDialog
        //title: "提示"
        standardButtons: Dialog.Ok
        //title:qsTr("保存成功！")
        modal: true
        closePolicy: "CloseOnEscape"
        //onAccepted: holdSaveOKDialog.close()
        z:100
        //onRejected: console.log("Cancel clicked")
    }
}

